module.exports = image => {
  fetch("http://api.hipicture.top/photos", {
    method: 'POST',
    headers: {
      'access-token': sessionStorage.getItem('picture-token'),
      Accept: "application/json",
      'Content-Type': "application/json",
    },
    body: JSON.stringify({
      brife: localStorage.getItem('brife'),
      img: image.replace(/^data:image\/(png|jpg);base64,/, ""),
    }),
  })
    .then(response => {
      if (response.status >= 200 && response.status < 300) {
        window.location.replace('/#/pic/success');
      } else {
        window.location.replace('/#/pic/failed');
      }
    });
};
